package com.yonyou.pmclouds.processphoto.process;

import com.yonyou.pmclouds.basecom.billstatus.BillStatusConst;
import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.consts.BillTypeConst;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.processphoto.entity.ProcessPhotoBillStatus;
import com.yonyou.pmclouds.processphoto.entity.ProcessPhotoVO;
import org.apache.commons.lang3.StringUtils;

public class ProcessPhotoBeforeAddProcess implements SingleProcessor<ProcessPhotoVO> {

    @Override
    public void process(ProcessPhotoVO vo, ProcessPhotoVO orig) throws BusinessException {
        if(vo == null) {
            throw new BusinessException("新增工序拍照为空,请检查!");
        } else if(StringUtils.isEmpty(vo.getPk_process())) {
            throw new BusinessException("未选择工序!");
        } else if(vo.getPictures().length == 0) {
            throw new BusinessException("图片未上传!");
        }
        // 设置单据类型
        vo.setBill_type(BillTypeConst.PROCESSPHOTO_BILLTYPE);
        // 设置单据状态为审批通过
        vo.setBillstatus(BillStatusConst.COMMON_FREE_STATUS);
    }

}
